#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(int i = l;i <= r;i++)
const int N = 2e3+10;
ll p = 1000000007;
ll qpow(ll a,ll b){
ll res = 1;
while(b){
if(b&1)res = res*a%p;
a = a*a%p;
b >>= 1;
}
return res;
}
ll inv2 = qpow(2,p-2);
ll dp[N][N],n,m,aa[N],ck[N][N];
ll dfs(int x,int y){
// cerr<<'*'<<'\n';
if(y == m+1)return m-x+1;
if(x == y)return 0;
if(ck[x][y])return dp[x][y];
ck[x][y] = 1;
dp[x][y] = (dfs(x+1,y)+1+dfs(x,y+1))*inv2%p;
return dp[x][y];
}
void solve(){
cin>>n>>m;
rep(i,1,n)cin>>aa[i];
aa[n+1] = m+1;
ll ans = 0;
rep(i,1,n){
ans += dfs(aa[i],aa[i+1]);
ans %= p;
}
cout<<ans<<'\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
solve();
return 0;
}
981A - Antipalindrome | 365A - Good Number |
1204B - Mislove Has Lost an Array | 1409D - Decrease the Sum of Digits |
1476E - Pattern Matching | 1107A - Digits Sequence Dividing |
1348A - Phoenix and Balance | 1343B - Balanced Array |
1186A - Vus the Cossack and a Contest | 1494A - ABC String |
1606A - AB Balance | 1658C - Shinju and the Lost Permutation |
1547C - Pair Programming | 550A - Two Substrings |
797B - Odd sum | 1093A - Dice Rolling |
1360B - Honest Coach | 1399C - Boats Competition |
1609C - Complex Market Analysis | 1657E - Star MST |
1143B - Nirvana | 1285A - Mezo Playing Zoma |
919B - Perfect Number | 894A - QAQ |
1551A - Polycarp and Coins | 313A - Ilya and Bank Account |
1469A - Regular Bracket Sequence | 919C - Seat Arrangements |
1634A - Reverse and Concatenate | 1619C - Wrong Addition |